package com.stockz.equity.indicator.vsa.property;

import java.util.List;

import com.stockz.equity.indicator.vsa.VsaBar;
import com.stockz.equity.model.Bar;

public class Close extends RangeEnum {

	public static final Close High = new Close("High",1,100,61);
	public static final Close Middle = new Close("Middle",2,60,41);
	public static final Close Low = new Close("Low",3,40,0);
	
	private static final Close[] closes = new Close[]{High,Middle,Low};
	
	public static Close[] values(){
		return closes;
	}
	
	public static void analyze(List<Bar> barList, int index, VsaBar vsaBar){
		if(barList == null || barList.isEmpty() ||
				index < 0 || index >= barList.size() ||vsaBar == null ){
			return;
		}
		double percentage = (barList.get(index).getClose()-barList.get(index).getLow())*100/barList.get(index).getSpread();
		for(Close close : Close.values()){
			if(percentage <= close.getUpperLimit() && percentage >= close.getLowerLimit()){
				vsaBar.setClose(close);
				break;
			}
		}
	}
	
	public Close(String name, int ordinal, double upperLimit, double lowerLimit) {
		super(name, ordinal, upperLimit, lowerLimit);
	}

}
